#include <bits/stdc++.h>
// 2025/02/06
// tag: 
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

#define int long long

int n, m, qb, K[150], C[150], dp[1000001];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> K[i];
    for (int i = 1; i <= n; i++)
        cin >> C[i], qb += K[i] * C[i];
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
        for (int k = qb; k >= 0; k--)
            for (int j = 1; j <= K[i] && k - C[i] * j >= 0; j++)
                dp[k] = max(dp[k], dp[k - C[i] * j] * j);
    for (int i = 0; i <= qb; i++)
        if (dp[i] >= m){
            cout << i << endl;
            return 0;
        }
    cout << -1;
    return 0;
}